# SQL queries to populate "table" content

# Put no semi-colon (;) at the end of the SQL statements so that they can be completed by the system.
# The first field in the query will be used as the key for the record if one is required.
# The keys in %tables and %entries MUST be valid Javascript identifiers.

our %views = (
    
    'ui_summary' => <<'SQL',

    SELECT 
        b.label AS "Group Name <ui_group/label>",
        COUNT(ui_user_pk) AS "# of Logins"
    FROM ui_user_group LEFT OUTER JOIN ui_group b ON (b.pk = ui_user_group.ui_group_pk)
    WHERE $constraints(ui_user_group)
    GROUP BY b.label
SQL

    'phone_login' => <<'SQL',

    SELECT
        b.label AS "Phone",
        "line".rank AS "Line #",
        login AS "SIP Login",
        password AS "SIP Password"
    FROM "line" LEFT OUTER JOIN phone b ON (b.pk = "line".phone)
    WHERE $constraints(line)
    GROUP BY b.label
SQL
     
);
